<template>
  <div>
    <!-- 数据列表 -->
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" label="编号" width="300" align="center">
      </el-table-column>
      <el-table-column prop="name" label="能耗项" width="300" align="center">
      </el-table-column>
      <el-table-column
        prop="projectType"
        label="项目类型"
        width="300"
        align="center"
      >
        <template slot-scope="scope">
          <el-tag v-if="scope.row.projectType === 0">生产用电</el-tag>
          <el-tag v-if="scope.row.projectType === 1">办公用电</el-tag>
          <el-tag v-if="scope.row.projectType === 2">生产用水</el-tag>
          <el-tag v-if="scope.row.projectType === 3">办公用水</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        prop="timeType"
        label="时间类型"
        width="300"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="energyConsumptionAmount"
        label="能耗数"
        width="300"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="warningThreshold"
        label="预警阈值"
        width="300"
        align="center"
      >
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="300" align="center">
        <template slot-scope="scope">
          <el-button @click="handleUpdate(scope.row)" type="text" size="small">
            修改
          </el-button>
          <el-button @click="handleDelete(scope.row)" type="text" size="small"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getFixedEmissions, delFixedEmissions } from "@/api/dc/fixedEmissions";
export default {
  name: "FixedEmissions",
  data() {
    return {
      tableData: null,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 查询数据列表
    getList() {
      getFixedEmissions().then((response) => {
        this.tableData = response.rows;
      });
    },
    // 删除数据
    handleDelete(id) {
      delFixedEmissions(id.id).then(() => {
        this.getList();
      });
    },
    // 修改数据
    handleUpdate(row) {
      console.log(row);
    },
  },
};
</script>